#include <stdio.h>
#include <stdlib.h>
#include "dtk.h"

int test1()
{
	DTKActor *stage, *scene;
	DTKActor *actor1, *actor2;
	DTKLayout* layout;
	DColor bgcolor = {0xff, 0x00, 0x00, 0xff};

	stage = dtk_stage_new(NULL);
	dtk_actor_set_size(stage, 480, 260);
	dtk_actor_set_bgcolor (stage, &bgcolor);
	scene = dtk_scene_new();
	layout = dtk_stack_layout_new (scene, DTK_HORIZONTAL);
	dtk_actor_set_layout(scene, layout);

	dtk_actor_set_size(scene, 350, 272);
	bgcolor.red = 0;
	bgcolor.blue = 0x55;
	dtk_actor_set_bgcolor (scene, &bgcolor);
	dtk_actor_add(stage, scene, NULL);	
	actor1 = dtk_texture_new_from_file("texture.png");
	actor2 = dtk_text_new_with_text("vera.ttf",
			 "hello world. used texture.png", 24);
	dtk_actor_set_position (actor1, 200, 10);
	dtk_actor_set_size (actor1, 50, 50);
	bgcolor.red = 0xff;
	dtk_actor_set_bgcolor(actor1, &bgcolor);
	dtk_actor_set_margin(actor1, 10, 10, 10, 10);
	bgcolor.blue = 0x7f;
	bgcolor.red = 0x7f;
	bgcolor.green = 0xff;
	dtk_actor_set_bgcolor(actor2, &bgcolor);
	dtk_actor_set_position (actor2, 50, 50);
	dtk_actor_set_margin(actor2, 10, 10, 10, 10);
	dtk_actor_set_size(actor2, 100, 100);
	dtk_actor_set_zOrder (actor2, 5);
	dtk_text_set_line_mode (actor2, DTK_FALSE);

	dtk_actor_add (scene, actor1, actor2, NULL);

	dtk_actor_show_all(stage);
}

int test2()
{
	DTKActor *stage, *scene;
	DTKActor *actor1, *actor2;
	DColor color={0x34, 0x78, 0xb7, 0xff}, bgcolor;

	stage = dtk_stage_new(NULL);
	scene = dtk_scene_new();

	bgcolor.green = 0x66;
	bgcolor.red = 0xff;
	bgcolor.blue = 0x55;
	dtk_actor_set_bgcolor (scene, &bgcolor);


	dtk_actor_set_size(scene, 480, 272);
	dtk_actor_add(stage, scene, NULL);
	actor1 = dtk_rectangle_new();
	actor2 = dtk_rectangle_new();
	dtk_actor_set_position (actor1, 10, 10);
	dtk_actor_set_size(actor1, 200, 100);

	dtk_actor_set_position (actor2, 210, 20);
	dtk_actor_set_size(actor2, 160, 160);
	dtk_actor_set_margin (actor2, 10, 10, 10, 10);
	dtk_rectangle_set_line_width (actor2, 10);
	dtk_rectangle_set_color(actor2, &color);

	dtk_actor_add(scene, actor1, actor2, NULL);
	dtk_actor_show_all(stage);
}

int test3()
{
	DTKActor *stage, *scene;
	DTKActor *actor1;
	DColor color={0x34, 0x78, 0xb7, 0xff};

	stage = dtk_stage_new(NULL);
	scene = dtk_scene_new();

	dtk_actor_set_size(scene, 480, 272);
	dtk_actor_add(stage, scene, NULL);
	
	actor1 = dtk_button_new();
	dtk_actor_set_position (actor1, 10, 10);
	dtk_actor_set_size(actor1, 200, 100);


	dtk_actor_add(scene, actor1, NULL);

	dtk_actor_show_all(stage);
}

int main(int argc, char* argv[])
{
	dtk_init (&argc, &argv);

	test1();
	//test2();
	//test3();
	printf ("HelloWorld.\n");
	dtk_loop();
	return 0;
}
